package com.balakitbbs.controller;

import org.springframework.beans.factory.annotation.Autowired; 
import java.util.*;               
import org.springframework.stereotype.Controller;               
import org.springframework.web.bind.annotation.PathVariable;               
import org.springframework.web.bind.annotation.RequestMapping;               
import org.springframework.web.servlet.ModelAndView;               
import com.balakitbbs.page.Page;               
import com.balakitbbs.page.SearchPageUtil;               
import com.balakitbbs.service.Bala_messageService;
import com.balakitbbs.entity.Bala_message;
   /**
    * bala_message Controller类
    */ 
@Controller
public class Bala_messageController{
	@Autowired
	private Bala_messageService bala_messageservice;

//增加消息表
@RequestMapping("/page/{pageIndex}/{pageSize}/addBala_message")
public String addBala_message(Bala_message bala_message,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_message.setCdate(new Date());
	bala_message.setId(UUID.randomUUID().toString());
	bala_messageservice.addBala_message(bala_message);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_message.do";
}


//删除消息表
@RequestMapping("/page/{Id}/{pageIndex}/{pageSize}/delBala_message")
public String delBala_message(@PathVariable String Id,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_messageservice.delBala_message(Id);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_message.do";
}


//修改消息表
@RequestMapping("/page/{pageIndex}/{pageSize}/updateBala_message")
public String updateBala_message(Bala_message bala_message,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_message.setUdate(new Date());
	bala_messageservice.updateBala_message(bala_message);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_message.do";
}


//查询消息表
@RequestMapping("/page/{pageIndex}/{pageSize}/selectBala_message")
public ModelAndView selectBala_messages(Bala_message bala_message,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	ModelAndView modelAndView = new ModelAndView();
	int selectBala_messageCount = bala_messageservice.selectBala_messagesByPOJOCount(bala_message);
	Page page = new Page(pageIndex, pageSize, selectBala_messageCount);
	SearchPageUtil spu = new SearchPageUtil();
	spu.setPage(page);
	modelAndView.addObject("data", bala_messageservice.selectBala_messagesByPojoPage(spu, bala_message));
	modelAndView.addObject("page", page);
	modelAndView.addObject("s", 1);
	modelAndView.addObject("po", new Bala_message());
	modelAndView.setViewName("/WEB-INF/page/bala_message.jsp");
	return modelAndView;
}

}

